﻿#region Using directives

using System;
using System.ComponentModel;

#endregion

namespace NetROS.Tiers.Entities
{	
	///<summary>
	/// An object representation of the 'tblObracunKamataShemaKnjiz' table. [No description found the database]	
	///</summary>
	/// <remarks>
	/// This file is generated once and will never be overwritten.
	/// </remarks>	
	[Serializable]
	[CLSCompliant(true)]
	public partial class ObracunKamataShemaKnjiz : ObracunKamataShemaKnjizBase
	{		
		#region Constructors

		///<summary>
		/// Creates a new <see cref="ObracunKamataShemaKnjiz"/> instance.
		///</summary>
		public ObracunKamataShemaKnjiz():base(){}	
		
		#endregion

        protected override void AddValidationRules()
        {
            base.AddValidationRules();
            //Validation rules based on database schema.

            ValidationRules.AddRule(ValidateDatumOdzaSifruNijeUIntervalima, new NetROS.Tiers.Entities.Validation.ValidationRuleArgs("KontoZaPrebacivanje", "KontoZaPrebacivanje"));
        }
        private bool ValidateDatumOdzaSifruNijeUIntervalima(object target, NetROS.Tiers.Entities.Validation.ValidationRuleArgs e)
        {
            if (this.ParentCollection != null && this.ParentCollection as TList<ObracunKamataShemaKnjiz> != null)
            {
                TList<ObracunKamataShemaKnjiz> _tlist = this.ParentCollection as TList<ObracunKamataShemaKnjiz>;

                foreach (ObracunKamataShemaKnjiz _shema in _tlist)
                {
                    if (_shema != this)
                    {
                        if (_shema.KontoZaPrebacivanje == this.KontoZaPrebacivanje && _shema.DugIliPot == this.DugIliPot)
                        {
                            e.Description = "Konto i strana već izbrana za taj tip dokumenta";
                            return false;
                        }
                    }

                }
            }
            return true;
        }
        ///<summary>
        ///</summary>
        [DescriptionAttribute(""), System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)]
        [DataObjectField(false, false, false)]
        public virtual Boolean Dug
        {
            get { return !DugIliPot; }
            set { DugIliPot = !value; }
        }
        ///<summary>
        ///</summary>
        [DescriptionAttribute(""), System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)]
        [DataObjectField(false, false, false)]
        public virtual System.Boolean Pot
        {
            get { return DugIliPot; }
            set { DugIliPot = value; }
        }
	}
}
